﻿using System;

namespace ConsoleApp2
{
    class Program
    {
        public  static void Print(Calculate calculate) {

            Console.WriteLine("请选择要输入的运算符：+ - * /");
            string str1 = Console.ReadLine();
            char v = char.Parse(str1);

            switch (v)
            {
                case '+':

                    Add add = new Add();
                    add.P();
                    add.DisplayResult();
                    break;
                case '-':
                    Sub sub = new Sub();
                    sub.P();
                    sub.DisplayResult();

                    break;
                case '*':
                    Mul mul = new Mul();
                    mul.P();
                    mul.DisplayResult();
                    break;
                case '/':
                    Div div = new Div();
                    div.P();
                    div.DisplayResult();
                    break;

            }
        }
        static void Main(string[] args)
        {
            //一、编写一个控制台应用程序，接受用户输入的两个整数和一个操作符，
            //以实现对两个整数的加、减、乘、除运算，并显示出计算结果。
            Calculate calculate = new Calculate();
            Print(calculate);

        }
    }
    class Calculate
    {
        protected int a;
        protected int b;
        public void P() {
            Console.WriteLine("请输入您要进行运算的第一个数");
            string str = Console.ReadLine();
            a = int.Parse(str);
            Console.WriteLine("请输入您要进行运算的第二个数");
            string str2 = Console.ReadLine();
            b = int.Parse(str2);
        }
        public virtual void DisplayResult()
        {

        }
    }
    class Add : Calculate
    {
        public override void DisplayResult()
        {

            Console.WriteLine("加法运算结果为：" + (a + b));
        }

    }
    class Sub:Calculate {
        public override void DisplayResult()
        {

            Console.WriteLine("减法运算结果为：" + (a - b));
        }

    }
    class Mul : Calculate
    {
        public override void DisplayResult()
        {

            Console.WriteLine("乘法运算结果为：" + (a* b));
        }

    }
    class Div : Calculate
    {
        public override void DisplayResult()
        {

            Console.WriteLine("除法运算结果为：" + (a / b));
        }

    }
}
